package com.wyg.iterator;

import java.util.Iterator;

/**
 * @description:
 * @author: WYG
 * @time: 2021/4/6 9:19
 */

public class Waitress {
    private PancakeHouseMenu pancakeHouseMenu;
    private DinerMenu dinerMenu;

    public Waitress(PancakeHouseMenu pancakeHouseMenu, DinerMenu dinerMenu) {
        this.pancakeHouseMenu = pancakeHouseMenu;
        this.dinerMenu = dinerMenu;
    }

    public void printMenu() {
        Iterator pancakeHouseMenuIterator = pancakeHouseMenu.createIterator();
        com.wyg.iterator.Iterator menuIterator = dinerMenu.createIterator();
        System.out.println("menu breakfast");
        printMenu(pancakeHouseMenuIterator);
        System.out.println("Lunch");
        printMenu(menuIterator);
    }
    private void printMenu(Iterator iterator) {
        while (iterator.hasNext()) {
            MenuItem next = (MenuItem) iterator.next();
            System.out.println(next);
        }
    }
    private void printMenu(com.wyg.iterator.Iterator iterator) {
        while (iterator.hasNext()) {
            MenuItem next = (MenuItem) iterator.next();
            System.out.println(next);
        }
    }

    public static void main(String[] args) {
        PancakeHouseMenu pancakeHouseMenu = new PancakeHouseMenu();
        DinerMenu dinerMenu = new DinerMenu();
        Waitress waitress = new Waitress(pancakeHouseMenu, dinerMenu);
        waitress.printMenu();
    }
}
